{include file="public/header"}
{load href="/public/static/Content/ThemesBusiness/ListPage.css"}
<script src="/public/static/Scripts/common-binder-list-view.js"></script>
<script src="/public/static/Scripts/ScriptsEasyui/datagrid-filter.js"></script>

    <script type="text/javascript">

        var data = null;
        var gridListHandler = new listGridHandler(data, 'gridListHandler', 'gridList');
        gridListHandler.formName = '管理员组';
        gridListHandler.enableFilter = false;
        $(function(){
            gridListHandler.bindFilter($('#gridList'));
        });

        function ShowNew() {
            var id = undefined;
            window.showBusinessForm("新建菜单", '/admin/usergroup/add.html?id=' + id );
        }


        function EditRecord(id) {
            //alert(id);return;
            if (id <= 0) {
                $.messager.alert('提示', "没有ID", 'info');
                return 0;
            }else{
               window.showBusinessForm("管理员组编辑", '/admin/usergroup/add.html?id=' + id);  
            }
           
          
        }

           function show(id) {
           
            if (id <= 0) {
                $.messager.alert('提示', "没有ID", 'info');
                return 0;
            }else{
               window.showBusinessForm("管理员", '/admin/usergroup/admin.html?id=' + id);  
            }
           
          
        }
         function auth(id) {
             $.messager.alert('提示', "开发中", 'error');
             return false;
            // if (id <= 0) {
            //     $.messager.alert('提示', "没有ID", 'info');
            //     return 0;
            // }else{
            //    window.showBusinessForm("管理员", '/admin/usergroup/admin.html?id=' + id);  
            // }
           
          
        }



       function del(id){
            if (id <= 0) {
                $.messager.alert('提示', "删除失败", 'info');
                return 0;
            }
      
            $.messager.confirm('删除确认', '确实要删除选中的记录？', function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        url: '/admin/usergroup/del.html?id=' + id,
                    })
                    .success(function (result) {
                        if (result.status > 0) {
                            $.messager.alert('提示', result.msg, "info");
                            window.location.reload();
                        }else {
                            $.messager.alert('提示', result.msg, "error");
                        }
                    })
                    .error(function (result) {
                        var message = "很抱歉，操作出现异常！请联系管理员。";
                        if (result) {
                            if (result.responseJSON && result.responseJSON.ExceptionMessage) {
                                message = result.responseJSON.ExceptionMessage;
                            }
                            else if (result.responseText) {
                                message = result.responseText;
                            }
                        }

                        $.messager.alert('错误', message.replace("-10", ""), 'error');
                    });
                }
            });
           
    }

        function formatAction(val, row, index) {
        
            val = '{eq name="power.edit" value="true"}<a href="#" style="float:left" title="编辑" onclick="EditRecord('+row.id+')"><div class="icon-page-edit"></div></a>{/eq}'+
                  '{eq name="power.del" value="true"}<a href="#" style="float:left" title="删除" onclick="del('+row.id+')"><div class="icon-page-delete"></div></a>{/eq}';

            return val;
  
        }

          function adminnumAction(val, row, index) {
        
            val = '<a href="#" style="color:#1024EE;text-decoration:underline" onclick="show('+row.id+')">'+row.adminnum+'人</a>';
            return val;
  
        }


        function authAction(val, row, index) {
        
            val = '<a href="#" style="color:#1024EE;text-decoration:underline" onclick="auth('+row.id+')">分配权限</a>';
            return val;
  
        }

    </script>
    

<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',border:false" class="grid-toolbar-panel" id="gridList_ToolBar">
        {eq name="power.add" value="true"}
        <a href="#" id="news" onclick="ShowNew()" class="easyui-linkbutton grid-toolbar-button" data-options="iconCls:'icon-add'" title="新建">新建</a>
        {/eq}
    </div>
    <div data-options="region:'center',border:false">
        <table id="gridList" exusagetype="MultiSelection" data-options="pagination:false,pageSize:15,pageList:[10,15,20],multiSort:true,remoteSort:true,striped:true,fit:true,fitColumns:true,rownumbers:true,idField:'id',singleSelect: true"
               url="/admin/usergroup/index.html?ajax=1">
            <thead data-options="frozen:true">
                <tr>
                     <th data-options="field:'id',width:100,halign:'center',align:'center',formatter:formatAction">操作</th>
                     <th  data-options="field:'name',halign:'center',align:'left',width:150"><span class="grid-header-sortable">管理组名称</span></th>
                     <th  data-options="field:'addtime',halign:'center',align:'left',width:150"><span class="grid-header-sortable">添加时间</span></th>
                    
                     <th  data-options="field:'adminnum',halign:'center',align:'center',width:150,formatter:adminnumAction"><span class="grid-header-sortable">成员</span></th>

                      <!-- <th  data-options="field:'rule',halign:'center',align:'left',width:150,formatter:authAction"><span class="grid-header-sortable">权限</span></th> -->
                </tr>
            </thead>
        
        </table> 

        
        </div>
    </div>
{include file="public/footer"/}